package cn.longge.service.impl;

import cn.longge.entity.SysResource;
import cn.longge.mapper.SysResourceMapper;
import cn.longge.service.ISysResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class SysResourceServiceImpl extends BaseServiceImpl<SysResource> implements ISysResourceService {
    @Autowired
    private SysResourceMapper resourceMapper;

    @Override
    public Map<String, List<SysResource>> selectByRid(Long rid) {
        List<SysResource> sysResources1 = resourceMapper.selectByRid(rid);
        SysResource sysResource = new SysResource();
        sysResource.setDelFlag("0");
        List<SysResource> sysResources2 = this.select(sysResource);
        Map<String, List<SysResource>> map = new HashMap<String, List<SysResource>>();
        map.put("allResource",sysResources2);
        map.put("resource",sysResources1);
        return map;
    }

    @Override
    public List<SysResource> selectByUid(Long uid) {
        return resourceMapper.selectByUid(uid);
    }

    @Override
    public List<SysResource> selectResource() {
        return resourceMapper.selectResource();
    }
}
